package cn.edu.cumt.ec.demo.controller;

import cn.edu.cumt.ec.demo.vo.UserVo;
import cn.edu.cumt.ec.demo.entity.User;
import cn.edu.cumt.ec.demo.service.IUserService;
import cn.edu.cumt.ec.demo.vo.mapper.UserMapper;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;


@RestController
@Api(value = "用户相关的操作")
@RequestMapping("/users")
public class UserController {
    @Autowired
    private IUserService userService;
    @GetMapping("/id")
    public UserVo getById(@RequestParam("userId") Integer userId){
        return UserMapper.INSTANCE.userToUserVo(userService.getById(userId));
    }
    @GetMapping("")
    public List<UserVo> list(){
        return UserMapper.INSTANCE.userToUserVo(userService.list());
    }
}